/**********************************************************************************
***
***    Screencasting Teaching System C++ Library
***    Copyright (C) 2011  Jiri Novak <jiri.novak@petriny.net>
***                        Wadi Jalil Maluf <wadijm@gmail.com>
***
***    This file is part of the Screencasting Teaching System C++ Library.
***
***    This library is free software; you can redistribute it and/or modify
***    it under the terms of the GNU General Public License as published by
***   the Free Software Foundation; either version 3 of the License, or
***    (at your option) any later version.
***
***    This library is distributed in the hope that it will be useful,
***    but WITHOUT ANY WARRANTY; without even the implied warranty of
***    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
***   GNU General Public License for more details.
***
***    You should have received a copy of the GNU General Public License
***    along with this library; if not, write to the Free Software
***    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
***
*********************************************************************************/


#ifndef CLIENTATTENDER_H_
#define CLIENTATTENDER_H_
#include "../common/comm/thread.h"
#include "../common/comm/operation.h"
#include "../common/comm/protocol.h"
#include "../common/comm/sockettcp.h"
#include "../common/comm/socketmsgsender.h"
#include "../common/comm/blockingqueue.h"
#include "scpersistenceservice.h"
#include <log4cxx/logger.h>
#include "clientservice.h"
#include "screencastservice.h"
/**
 * Clase que se encarga de atender las peticiones de un cliente en particular. Es creada y destruida por ClientListener.
 */
class ClientAttender:public Thread {
public:
  ClientAttender(SocketTcp* cliente,ClientService& service,ScreencastService & s,std::string confPath);
    virtual ~ClientAttender();
    virtual void run();
    virtual void start();
    bool isClosed();
    void freeResources();

private:
    Protocol protocol;
    User* user;
    SocketTcp* cliente;
    Lesson* currentLesson;
    bool closed;
    bool recordingScreencast;
    ClientService& service;
    ScreencastService& screencastService;
    ScPersistenceService* scPersistenceService;
    std::string confPath;
    void processRequest(Operation& op);
    log4cxx::LoggerPtr logger_;
    SocketMsgSender* sender;
    BlockingQueue queue;
};

#endif /* CLIENTATTENDER_H_ */
